<%--
  Created by IntelliJ IDEA.
  User: TYZ
  Date: 2020/3/12
  Time: 19:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/common/common.jsp" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<div class="row">

    <div class="row">
        <div class="col-lg-12">
            <center><font size="7" color="blue">管理系统</font></center>
            &nbsp&nbsp&nbsp&nbsp&nbsp欢迎你:${u.username }
            <img src="<%=path%>/file/download?filename=${u.uimg }" width="100px" height="100px"/><br>
            &nbsp&nbsp&nbsp&nbsp&nbsp<a href="javascript:toLoginOut()">退出登录</a>
        </div>
        <div class="col-lg-3">
            <div id="tree"></div>
        </div>
        <div class="col-lg-9">
            <div class="tabbable">
                <!-- addtabs导航栏 -->
                <ul class="nav nav-tabs" id="myTab"></ul>
                <!-- addtabs内容 -->
                <div class="tab-content"></div>
            </div>
        </div>
    </div>
</div>
</body>
<script type="text/javascript">
    function getTree() {
        var tree = [];
        $.ajax({
            url:"<%=path %>/menuController/getMenu",
            type:"get",
            dataType:"json",
            async:false,
            success:function(data){
                tree = data;
            },
            error:function(){
                toastr.error("系统异常,请联系管理员");
            }
        })
        return tree;
    }

    $(function() {
        $("#tree").treeview({
            data:getTree(),
            borderColor : "blue",
            onNodeSelected : function(event, data){
                if(data.nodes == undefined){
                    /* alert("执行地址请求" + node.url); */
                    $.addtabs.add({
                        title : data.text,
                        id : data.id,
                        url : "<%=path%>"+data.url
                    })
                }
            }
        })
    });

    function toLoginOut(){
        window.top.location.href="<%=path %>/userController/toLoginOut";
    }
</script>
</html>
